//---------------------------------------------------------------------
//  This file is part of the Background Motion solution.
// 
//  Copyright (C) Mindscape (TM).  All rights reserved.
//  http://www.mindscape.co.nz
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//---------------------------------------------------------------------

using System.Web.UI;
using System.Web.UI.HtmlControls;
using Mindscape.BackgroundMotion.Website.Controllers;
using Mindscape.BackgroundMotion.Website.Infrastructure;
using Mindscape.BackgroundMotion.Website.Views;

namespace Mindscape.BackgroundMotion.Website
{
  public partial class Search : PageBase<SearchPresenter, ISearchView, IContributionController>, ISearchView
  {
    /// <summary>
    /// Registers an RSS feed to be assigned to the search results
    /// </summary>
    public void RegisterRssFeed(string arguments)
    {
      foreach (Control control in Page.Header.Controls)
      {
        if (control.ID == "RssFeedHeader")
        {
          HtmlLink rssFeedHeader = control as HtmlLink;
          if ( rssFeedHeader != null ) rssFeedHeader.Href += arguments;
          break;
        }
      }
    }

    /// <summary>
    /// The results of the current search
    /// </summary>
    public ISearchResult Results
    {
      set
      {
        ResultsContributionGrid.Contributions = value.Contributions;
        PagingControl.SearchResults = value;
      }
    }

    /// <summary>
    /// Indicates if no data was found and an error message to that effect should be shown
    /// </summary>
    public bool DisplayNoDataMessage
    {
      set { NoResultsLiteral.Visible = value; }
    }
  }
}